package com.gao.controller;

import com.gao.annontation.StarAuthenticated;
import com.gao.entity.Product;
import com.gao.util.ResultVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gao
 * @time 2022/11/26 14:52:17
 */
@RestController
public class TestController {
    @Value("${server.port}")
    private int port;

    @StarAuthenticated
    @GetMapping("/products/lb")
    public ResultVO testLoadBalance() {
        return ResultVO.success("处理本次请求的star-product实例端口：" + port, null);
    }

    @PostMapping("/products/testObjectParam")
    public ResultVO testObjectParam(@RequestBody Product product) {
        return ResultVO.success(port + " 接收对象成功", product);
    }
}
